package sysLearn;

import java.sql.*;

/**
 * @program: planet-company
 * @description:
 * @author: jyz
 * @create: 2019-08-29 20:54
 **/
public class ClassLearn {

    public static void main(String[] args) throws SQLException {
        String url = "jdbc:mysql://118.190.159.10:3306/test?characterEncoding=utf-8&useSSL=false";
        String username = "root";
        String password = "Yasong0120.";
        Connection conn = null;
        try {
            conn = DriverManager.getConnection(url, username, password);
            PreparedStatement statement = conn.prepareStatement("select * from user where id = ?");
            statement.setLong(1,1);
            ResultSet set = statement.executeQuery();
            while(set.next()){
                System.out.println(set.getString("name"));
            }
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            if(conn!=null){
                try {
                    conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
